package com.shierke.Ume.base

import android.app.Application
import android.content.Context
import com.shierke.Ume.BuildConfig
import com.shierke.Ume.util.LanguageUtil
import com.shierke.Ume.util.config
import com.xbxm.retrofiturlmanager.L
import com.xbxm.retrofiturlmanager.RetrofitUrlManager


/**
 * Create by Ybx
 * on 2020-10-11
 * Desribe:
 */
class App : Application() {

    override fun onCreate() {
        super.onCreate()
        languageWork()
        initLog()
        initRetrofit()
    }


    //切换语言
    private fun languageWork() {
        //val locale = LanguageUtil.getLocale(this)
        // LanguageUtil.updateLocale(this, locale)
    }


    override fun attachBaseContext(base: Context?) {
        super.attachBaseContext(base)
    }


    private fun initRetrofit() {

        RetrofitUrlManager.header =
            "${context?.config?.tokenType}${context?.config?.accessToken}"
    }


    private fun initLog() {
        L.tag(BuildConfig.APPLICATION_ID)
        L.setLogEnable(true)
    }


    companion object {

        private var context: App? = null
        fun appContext(): Context = context!!
    }


}

